package com.qf.mapper;

import com.qf.pojo.DtsOrder;
import com.qf.pojo.DtsOrderGoods;
import com.qf.vo.CategorySellAmts;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * projectName:workspace_6
 * author:hyn
 * time:2021/11/24 22:29
 * description:
 */
public interface DtsOrdersGoodsMapper {
    @Select("SELECT c.name AS name,SUM(og.price) AS value FROM dts_order_goods og JOIN dts_order o ON o.id = og.order_id JOIN dts_goods g ON g.id = og.goods_id JOIN dts_category c ON g.category_id = c.id WHERE og.deleted=0 AND o.order_status NOT IN(101,102,103) GROUP BY c.name limit 3")
    List<CategorySellAmts> findNameAndValue();

    @Select("SELECT DATE_FORMAT(add_time,'%Y-%m-%d') AS mobile,user_id,order_price " +
            "FROM dts_order WHERE order_status NOT IN (101,102,103) AND deleted = 0 AND " +
            "add_time > DATE_ADD(DATE_FORMAT(NOW(),'%Y-%m-%d'),INTERVAL #{day} DAY) ORDER BY add_time")
    List<DtsOrder> findOrderAndUser(int day);
    @Select("select *from dts_order_goods where order_id = #{id}")
    List<DtsOrderGoods> findByOrderId(Integer id);
}
